# Contributor: Marian Buschsieweke <marian.buschsieweke@ovgu.de>
# Maintainer: Marian Buschsieweke <marian.buschsieweke@ovgu.de>
pkgname=hackrf
pkgver=2021.03.1
pkgrel=1
pkgdesc="Driver for HackRF, allowing general purpose software defined radio"
url="https://github.com/mossmann/hackrf"
arch="all"
license="GPL-2.0-only"
options="!check"  # no test suite
makedepends="libusb-dev fftw-dev cmake"
subpackages="
	$pkgname-static
	$pkgname-dev
	$pkgname-firmware:firmware:noarch
	$pkgname-libs
	"
source="$pkgname-$pkgver.tar.xz::https://github.com/mossmann/hackrf/releases/download/v$pkgver/hackrf-$pkgver.tar.xz"

build() {
	cmake -B build \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		host
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --build build --target install
}

firmware() {
	pkgdesc="$pkgdesc (firmware)"

	find "$builddir/firmware-bin" -type f -exec install -Dm644 -t "$subpkgdir/usr/share/hackrf/" {} \;
}

sha512sums="
4a88b877a9f6fee0c8d9496eb265655af4baa678e862ca6147596cd3a1d85dd50315da6531efa54d050847ce5068c4726393b4897d40576888d10a898ad57139  hackrf-2021.03.1.tar.xz
"
